package com.example.tests;

import static org.junit.Assert.assertEquals;

import org.openqa.selenium.By;
import org.testng.annotations.Test;

import com.example.framework.AppUnderTest;

public class UserRegister extends BaseTestSetUp {

	@Test
	public void registerNewUser() throws Exception {
		app.navigateTo().homePageByUrl();

		app.assertHomePageIsOpened();
		app.driver.findElement(By.linkText("Register")).click();

		app.assertRegisterPageIsOpened();

		app.fillRegisterForm(new UserRegisterFormParameter());
		AppUnderTest.newUserLogin = UserRegisterFormParameter.getUserLogin();
		AppUnderTest.newUserFirstName = UserRegisterFormParameter.getUserFirstName();
		AppUnderTest.newUserLastName = UserRegisterFormParameter.getUserLastName();
		AppUnderTest.newUserEmail = UserRegisterFormParameter.getUserEmail();
		
		app.driver.findElement(By.name("commit")).click();

		try {
			assertEquals(AppUnderTest.HTTP_DEMO_REDMINE_ORG + AppUnderTest.MY_ACCOUNT,
					app.driver.getCurrentUrl());
		} catch (Error e) {
			app.verificationErrors.append(e.toString());
		}

		app.assertRegistrationSuccessfull();
		app.driver.findElement(By.xpath("/html/body/div/div/div/div/div/ul/li[2]/a")).click();
		//WebDriver augmentedDriver = new Augmenter().augment(app.driver);
        //File screenshot = ((TakesScreenshot)augmentedDriver).getScreenshotAs(OutputType.FILE);
	}

}
